<html>
<head><meta charset="utf-8"><title>AST visitor pattern · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/AST.20visitor.20pattern.html">AST visitor pattern</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225843921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/AST%20visitor%20pattern/near/225843921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/AST.20visitor.20pattern.html#225843921">(Feb 10 2021 at 14:32)</a>:</h4>
<blockquote>
<p>so what does visiting an expression mean in this context?</p>
</blockquote>
<p><span class="user-mention" data-user-id="372858">@boolean_coercion</span> it's a framework for looking at parts of an AST basically <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/visit/trait.Visitor.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/visit/trait.Visitor.html</a></p>



<a name="225845319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/AST%20visitor%20pattern/near/225845319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boolean_coercion <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/AST.20visitor.20pattern.html#225845319">(Feb 10 2021 at 14:40)</a>:</h4>
<p>I'm not sure I understand what's happening completely. Who (i.e. what part of the code) is using these Visitors? If you want to run a check on every expression of a structure recursively, do you define a visitor that overrides <code>visit_expr</code> and use it to check them somehow?</p>



<a name="225850059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/AST%20visitor%20pattern/near/225850059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/AST.20visitor.20pattern.html#225850059">(Feb 10 2021 at 15:12)</a>:</h4>
<p>yes, exactly</p>



<a name="225850108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/AST%20visitor%20pattern/near/225850108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/AST.20visitor.20pattern.html#225850108">(Feb 10 2021 at 15:12)</a>:</h4>
<p>there are a lot of different places that use visitors, you can search for <code>ast::Visitor</code> if you want to see them all</p>



<a name="225850341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/AST%20visitor%20pattern/near/225850341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boolean_coercion <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/AST.20visitor.20pattern.html#225850341">(Feb 10 2021 at 15:14)</a>:</h4>
<p>I see. Thanks <span aria-label="smiley" class="emoji emoji-1f603" role="img" title="smiley">:smiley:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>